home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-20 | 4.4 KB | 177 lines | [TEXT/ALFA] |
- # Usage: diff [-#] [-abBcdefhHilnNprstTuvw] [-C lines] [-F regexp] [-I regexp]
- # [-L label [-L label]] [-S file] [-D symbol] [+ignore-blank-lines]
- # [+context[=lines]] [+unified[=lines]] [+ifdef=symbol]
- # [+show-function-line=regexp]
- # [+speed-large-files] [+ignore-matching-lines=regexp] [+new-file]
- # [+initial-tab] [+starting-file=file] [+text] [+all-text] [+ascii]
- # [+minimal] [+ignore-space-change] [+ed] [+reversed-ed] [+ignore-case]
- # [+print] [+rcs] [+show-c-function] [+binary] [+brief] [+recursive]
- # [+report-identical-files] [+expand-tabs] [+ignore-all-space]
- # [+file-label=label [+file-label=label]] [+version] path1 path2
-
-
- proc compareDirectories {} {
- alertnote "Not yet"
- return
-
- set dir1 [string trimright [get_directory] {:}]
- set dir2 [string trimright [get_directory] {:}]
-
- set glob1 [glob -t TEXT "$dir1:*"]
- set glob2 [glob -t TEXT "$dir2:*"]
-
- new -n {* Directory Comparison *}
- insertText "Dir1 : \"$dir1\"\rDir2: \"$dir2\"\r"
- foreach f $glob1 {
- set tail [file tail $f]
- if {[lsearch $glob2 "*:$tail"] >= 0} {
- insertText "In both directories: $tail\r"
- message "Diffing '$tail'"
- insertText [xdiff "$dir1:$tail" "$dir2:$tail"] "\r"
- } else {
- insertText "Only in first: $tail\r"
- }
- }
- foreach f $glob2 {
- set tail [file tail $f]
- if {[lsearch $glob1 "*:$tail"] < 0} {
- insertText "Only in second: $tail\r"
- }
- }
- }
-
-
- proc compareFiles {} {
- global tileWidth tileHeight tileTop tileLeft
- global diffOne diffTwo
-
- set diffOne [getfile "Select your first file:"]
- set diffTwo [getfile "Select your second file:"]
-
- if {[lsearch [winNames -f] $diffOne] >= 0} {
- bringToFront $diffOne
- killWindow
- if {[lsearch [winNames -f] $diffOne] >= 0} {return}
- }
- if {[lsearch [winNames -f] $diffTwo] >= 0} {
- bringToFront $diffTwo
- killWindow
- if {[lsearch [winNames -f] $diffTwo] >= 0} {return}
- }
-
- set numWins 2
- set margin 4
- set width [expr ($tileWidth/$numWins)-$margin]
- set height [expr $tileHeight - 200]
- set hor $tileLeft
-
- edit -g $hor $tileTop $width $height $diffOne
- set diffOne [lindex [winNames -f] 0]
- incr hor [expr $width + $margin]
- edit -g $hor $tileTop $width $height $diffTwo
- set diffTwo [lindex [winNames -f] 0]
-
- doTheCompare
- }
-
-
- proc compareWindows {} {
- global tileWidth tileHeight tileTop tileLeft
- global diffOne diffTwo
-
- set wins [winNames -f]
- if {[llength $wins] < 2} {
- message "Need two windows"
- return
- }
- set diffOne [lindex $wins 0]
- set diffTwo [lindex $wins 1]
-
- set numWins 2
- set margin 4
- set width [expr ($tileWidth/$numWins)-$margin]
- set width [expr {$width + $margin / $numWins}]
- set height [expr $tileHeight - 200]
- set hor $tileLeft
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $wins $i] 1000 0
- sizeWin [lindex $wins $i] $width $height
- }
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $wins $i] $hor $tileTop
- set hor [expr $hor+$width+$margin]
- }
-
- doTheCompare
- }
-
-
- proc trimnum {str} {
- if {[regexp -indices { <[0-9]+>} $str ind]} {
- return [string range $str 0 [expr [lindex $ind 0] - 1]]
- } else {
- return $str
- }
- }
-
-
- proc doTheCompare {} {
- global tileLeft tileTop tileWidth tileHeight diffFlags
- global diffOne diffTwo winModes HOME
-
- launch "$HOME:Tools:GNU Diff"
- set dtext [dosc -n "GNU Diff" -s "$diffFlags \"[trimnum $diffOne]\" \"[trimnum $diffTwo]\""]
-
- set top [expr $tileTop + $tileHeight - 178]
- new -n {* File Comparison *} -g $tileLeft $top [expr $tileWidth - 6] 178
- changeMode [set winModes([lindex [winNames] 0]) Diff]
- insertText "\r$dtext\r"
- goto 0
- setWinInfo dirty 0
- select 1 [nextLineStart 1]
- }
-
-
- proc upDiff {} {
- set limit 0
- set res [search -f 0 -r 1 {^[^-<>]} [expr [getPos] - 1]]
- set pos [lindex $res 0]
- select $pos [nextLineStart $pos]
-
- }
-
- proc downDiff {} {
- set limit 0
- set res [search -f 1 -r 1 {^[^-<>]} [expr [getPos] + 1]]
- set pos [lindex $res 0]
- select $pos [nextLineStart $pos]
-
- }
-
- # n1 a n3,n4
- # n1,n2 d n3
- # n1,n2 c n3,n4
- proc selectDiff {} {
- global diffOne diffTwo
-
- set text [getText [lineStart [getPos]] [expr [nextLineStart [getPos]] - 1]]
-
- if {![regexp {[acd]} $text char]} return
- set res [split $text $char]
- if {![scan [lindex $res 0] "%d" one]} return
- if {![scan [lindex $res 1] "%d" two]} return
-
- display -w $diffOne [rowColToPos -w $diffOne $one 0]
- display -w $diffTwo [rowColToPos -w $diffTwo $two 0]
- }
-
-
- bind '\r' selectDiff Diff
- bind enter selectDiff Diff
- bind down downDiff Diff
- bind up upDiff Diff
-
-
-